package com.extension.company.view.appcome;

import android.content.Intent;
import android.os.Handler;
import android.util.Log;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.extension.company.admin.R;
import com.extension.company.common.mvc.BaseActivity;
import com.extension.company.common.utils.SharedPreferenceUtils;
import com.extension.company.view.main.MainActivity;
import com.jaeger.library.StatusBarUtil;

/**
 * 延迟进入广告位activity
 */
public class StartActivity extends BaseActivity {

	private Handler mHandler = new Handler();
	private boolean isFirstIn = false;
	private ImageView advertisingImg;
	private String url = "https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=402023167,2362430521&fm=15&gp=0.jpg";

	@Override
	public int getMainLayout() {
		return R.layout.activity_start;
	}

	@Override
	protected void initView() {
		StatusBarUtil.setTranslucentForImageView(this, 0, null);
		//隐藏状态栏
//		getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
//				WindowManager.LayoutParams.FLAG_FULLSCREEN);

		final boolean isFirstIn = SharedPreferenceUtils.getBoolean("isFirstIn", true);
		Log.d("zwk", "是否第一次进入" + isFirstIn);

		mHandler.postDelayed(new Runnable() {
			@Override
			public void run() {

				if (isFirstIn) {
					boolean isStory = SharedPreferenceUtils.addCache(new String[]{"isFirstIn"}, new Boolean[]{false});
					Log.d("zwk", "保存成功了吗" + isStory);
					if (isStory) {
						LeadActivity.Intent(StartActivity.this);
					}
				} else {
					Intent mainIntent = new Intent(StartActivity.this, MainActivity.class);
					startActivity(mainIntent);
				}
//				LoginActivity.startActivity(StartActivity.this);
				finish();
			}
		}, 3000);
		advertisingImg = getViewById(R.id.advertising);
	}

	@Override
	protected void initData() {
		Glide.with(StartActivity.this)
				.load(url)
				.into(advertisingImg);

	}

	@Override
	protected void initListener() {

	}
}
